package environment;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.geom.Ellipse2D;

public class Goal implements DrawableInterface
{
	protected int x,y; // center
	protected double radius;
	private Color goalColor = Color.yellow;
	private Ellipse2D.Double e;
	
	public Goal(int x, int y, double r)
	{
		this.x = x;
		this.y = y;
		radius = r;
		e = new Ellipse2D.Double(x - radius, y - radius, 2*radius, 2*radius);
	}
	
	/**
	 * Checks if all of box's points are in goal
	 * @param b
	 * @return
	 */
	public boolean contains(Box b)
	{
		return e.contains(b.p1) && e.contains(b.p2) && e.contains(b.p3) && e.contains(b.p4);
	}
	
	/**
	 * If any of the robot points is in goal, consider robot is in goal
	 * @param r
	 * @return
	 */
	public boolean contains(Robot r)
	{
		return e.contains(r.p0) || 
				e.contains(r.p1) || 
				e.contains(r.p2) || 
				e.contains(r.p3) || 
				e.contains(r.p4);
	}
	
	public void draw(Graphics g)
	{
		g.setColor(goalColor);
		g.fillOval((int)(x - radius), (int)(y - radius), (int)(2*radius), (int)(2*radius));
	}
}
